package com.Mapper;

import com.Entity.Film;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface FilmMapper {
    @Select("select * from film")
    List<Film> all();

    @Select("select * from film where id = #{id} ")
    Film byId();

    @Select("select * from film where name = #{name} ")
    Film byName();

    @Insert("insert into film(name, guide, starring, length, type, is3D, fare, vfare, release_data, score) " +
            "VALUES(#{name}, #{guide}, #{starring}, #{length}, #{type}, #{is3D}, #{fare}, #{vfare}, #{release_data}, #{score})")
    int insert(Film order);

    @Update("UPDATE film SET name = #{name}, guide = #{guide}, starring = #{starring}, length = #{length}, " +
            "type = #{type}, is3D = #{is3D}, fare = #{fare}, vfare = #{vfare}, " +
            "release_data = #{release_data}, score = #{score} WHERE id = #{id}")
    int update(Film order);

    @Delete("DELETE FROM film WHERE id = #{id}")
    int delete(Film order);
}
